{%macro item_actions(itm,small=False)%}
{%if current_user%}
<div class="actions">
	{%if current_user.key()!=itm.parent_key()%}
	<input type="button" value="{%if small%}Chat{%else%}Communicate with Seller{%endif%}" class="item-communicate-button" data-item="{{itm.token}}"/>
	{%endif%}
	{%if itm.removeable_by(current_user)%}{#all those who can edit item X can remove item X#}
	{%if itm.parent_key()==current_user.key()%}
	<a href="{{itm|url(action='edit')}}">Edit</a>
	{%endif%}
	<form action="{{itm|url(action='delete')}}" method="post" class="delete-form" data-completing-label="Deleting...">
		<input type="hidden" name="csrf_token" value="{{csrf_token}}"/>
		<input type="submit" value="Delete"/>
	</form>
	{%endif%}
</div>
{%endif%}
{%endmacro%}
{%macro item(itm)%}
<div class="item">
	<a class="thumbnail" href="{{itm|url}}" style="background-image:url('{{itm|url(named=False,action='picture')}}')"></a>
	<div class="details">
		<div class="container">
			<a class="name" href="{{itm|url}}">{{itm.name}}</a>
			<div class="price">{{itm.price|price}}</div>
			<div class="expiration">Expiration: {{convert_datetime(itm.expiration())|date}}</div>
			<div class="star-strip"><div style="width:{{itm.avg_rating}}%"></div></div>
			<div class="author"><a href="{{itm.parent()|url}}">{{itm.parent().nickname}}</a></div>
		</div>
	</div>
	<div class="description">
		<div class="container">
			{{itm.description|Markup}}
		</div>
	</div>
	{{item_actions(itm,small=True)}}
</div>
{%endmacro%}
